<?php 
ob_start();
session_start(); // on relaye la session

	if(isset($_SESSION["is_registered"]) && $_SESSION["is_registered"] == "registered")
	{
		$enregistrer = $_SESSION["is_registered"];
		function title()
		{
			$exp=explode("/",$_SERVER['REQUEST_URI']);
			$taille = sizeof($exp);
			$last = ucfirst( $exp[$taille-1] );
			$last = explode(".php",$last);
			return $last[0].' :: MicroAssur';
		}
		$titleGen = title();
		$message = "";
	}
	else
	{
		header("Location:index.php?erreur=intru"); // redirection en cas d'echec
	}
	
	$_SESSION['num_contrat']= NULL;
	unset ($_SESSION['num_contrat']);
	
require_once('Connections/microassur.php');
include_once('utils/functions.php');
?>
<?php
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != ""))
{
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true"))
{
  session_unset();
  $logoutGoTo = "index.php";
  if ($logoutGoTo) 
  {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
	function strToNoAccent($var)
	{
			$var = str_replace(
			 array(
			  "à", "â", "ä", "á", "ã", "å",
			  "î", "ï", "ì", "í",
			  "ô", "ö", "ò", "ó", "õ", "ø",
			  "ù", "û", "ü", "ú",
			  "é", "è", "ê", "ë",
			  "ç", "ÿ", "ñ","'",
			  "‘","'",
			 ),
			 array(
			  '&agrave;', '&#194;', '	&#196;', '&#193;', '&#195;', '&#197;',
			  '	&#206;', '&#207;', '&#204;', '&#205;',
			  '&#212;', '&#214;', '&#210;', '&#211;', '&#213;', '&#216;',
			  '&#217;', '&#219;', '&#220;', '&#218;',
			  '&eacute;', '&egrave;', '&#234;', '&#235;',
			  '&#199;', '&#255;', '&#241;','&#8217;',
			  '&#8217;','&#8217;',
			 ),$var);
		return $var;
	}
   	function colorer ($val,$val2)
	{
		$cls = '<div class='.$val2.'>'.strToNoAccent($val).'</div>';
		return $cls;
	}
	if (!function_exists("GetSQLValueString")) {
	function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
	{
	  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
	
	  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
	
	  switch ($theType) 
	  {
	    case "text":
	      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
	      break;    
	    case "long":
	    case "int":
	      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
	      break;
	    case "double":
	      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
	      break;
	    case "date":
	      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
	      break;
	    case "defined":
	      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
	      break;
	  }
	  return $theValue;
	}
}

$colname_rs = "-1";
if (isset($_SESSION['MM_UserGroup'])) 
{
  $colname_rs = $_SESSION['MM_UserGroup'];
}
mysql_select_db($database_microassur, $microassur);
$query_rs = sprintf("SELECT * FROM habilitation WHERE Identifiant_profil = %s", GetSQLValueString($colname_rs, "int"));
$rs = mysql_query($query_rs, $microassur) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);

	if(isset($_GET['modcontrac']) && ($_GET['modcontrac']==1))
	{
		unset($_SESSION['identifiant_contrat']);
		unset($_SESSION['numero_contrat']);
		unset($_SESSION['dateeffet_contrat']);
		unset($_SESSION['clausebeneficiaire_contrat']);
		unset($_SESSION['dateecheance_contrat']);
		unset($_SESSION['freqencepaiement_contrat']);
		unset($_SESSION['etat_contrat']);
		unset($_SESSION['formule']);
		unset($_SESSION['produit']);
		unset($_SESSION['offre']);
		unset($_SESSION['gar_optionnel']);
		unset($_SESSION['justificatif']);
		unset($_SESSION['paiement']);
		unset($_SESSION['ActiverRIB']);
		unset($_SESSION['ActiverValider']);
	}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=8" />
			<title><?php echo $titleGen ?></title>
			<link rel="stylesheet" type="text/css" href="css/main.css" />
			<!--[if IE 7]><link rel="stylesheet" type="text/css" href="css/ie7.css" /><![endif]-->
	</head>
<body>
		<div id="main_entete">
			<div id="logo"> </div>
			<div id="time"><?php  today(); ?></div>
		</div>
			<div class="cleared"></div>
			<div id="sf_menu">
				<div id="menu">
				   <ul class="niveau1">
					  <li class="sousmenu space"><a href="#">Administration</a>
						<?php //if(isset($ADMIN) && $ADMIN=="ADMIN"){ ?>
						 <ul class="niveau2 <?php echo isHabilitation('Administration',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>">
							<li class="sousmenu"><a href="#">Réseau distribution</a>
							   <ul 
                                  class="niveau3">
								  <li class="sousmenu"><a href="administration/reseaudedistribution/direction/">Direction</a></li>
								  <li class="sousmenu"><a href="administration/reseaudedistribution/region/">Région</a></li>
								  <li class="sousmenu"><a href="administration/reseaudedistribution/unite/">Unité</a></li>
								  <li class="sousmenu"><a href="administration/reseaudedistribution/agent/">Agent</a></li>
							   </ul>
							</li>
							<li class="sousmenu"><a href="#">Habilitations</a>
							   <ul class="niveau3">
								  <li class="sousmenu shab"><a href="administration/habilitations/profil/">Profil</a></li>
								  <li class="sousmenu shab"><a href="administration/habilitations/habilitation/">Habilitation</a></li>
							   </ul>
							</li>
							<li class="sousmenu"><a href="#">Utilisateurs</a>
								<ul class="niveau3">
								  <li class="sousmenu sut"><a href="administration/utilisateurs/fonction/">Fonction</a></li>
								  <li class="sousmenu sut"><a href="administration/utilisateurs/utilisateur/">Utilisateur</a></li>
								</ul>
							</li>
							<li class="sousmenu"><a href="#">Dictionnaire</a>
								<ul class="niveau3">
								  <li class="sousmenu sdic"><a href="administration/dictionnaire1/dictionnaire/">Dictionnaire</a></li>
								  <li class="sousmenu sdic"><a href="administration/dictionnaire1/elementdico/">Elément du dictionnaire</a></li>
								</ul>
							</li>
							<li class="sousmenu"><a href="#">Offre</a>
								<ul class="niveau3">
								  <li class="sousmenu"><a href="administration/offre1/offre/">Offre</a></li>
								  <li class="sousmenu"><a href="administration/offre1/produit/">Produit</a></li>
								  <li class="sousmenu"><a href="administration/offre1/formule/">Formule</a></li>
								  <li class="sousmenu"><a href="administration/offre1/garantie/">Garantie</a></li>
								</ul>
							</li>
							<li class="sousmenu"><a href="#">Conditions vente</a>
								<ul class="niveau3">
								  <li class="sousmenu scv"><a href="administration/conditionvente1/conditionvente/">Condition vente</a></li>
								  <li class="sousmenu scv"><a href="administration/conditionvente1/tarif/">Tarif</a></li>
								</ul>
							</li>
							<li class="sousmenu"><a href="#">Conditions indemnisation</a>
								<ul class="niveau3">
								  <li class="sousmenu sci"><a href="administration/conditionsindemnisation/conditionindem/">Condition indemnisation</a></li>
								  <li class="sousmenu sci"><a href="administration/conditionsindemnisation/indemnisation/">Indemnisation</a></li>
								</ul>
							</li>
							
						 </ul>
						 <?php //} ?>
					  </li>
					  <!-- ******************************** -->
					  <li class="sousmenu"><a href="#">Partenaire</a>
						<?php //if(isset($PARTE) && $PARTE=="PARTE"){ ?>
						 <ul class="niveau2  <?php echo isHabilitation('Partenaire',$database_microassur, $microassur,$username_microassur, $password_microassur)?> ">
							<li class="sousmenu part"><a href="partenaire1/partenaire/">Gestion du partenaire</a></li>
							<li class="sousmenu part"><a href="partenaire1/partenaire/rattacherOffre.php">Rattachement de l’offre au partenaire</a></li>
						 </ul>
						 <?php //} ?>
					  </li>
					  <!-- ******************************** -->
					  <li class="sousmenu"><a href="#">Synthèse</a>
						 <ul class="niveau2  <?php echo isHabilitation('Synthese',$database_microassur, $microassur,$username_microassur, $password_microassur)?> ">
							<li class="sousmenu syn <?php echo isHabilitation('Ficsy',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="synthese/index.php?idbloc=3&idfonction=30">Fiche synthèse</a></li>
							<li class="sousmenu syn <?php echo isHabilitation('Elems',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="synthese/stats.php?idbloc=3&idfonction=31">Eléments statistiques</a></li>
						 </ul>
					  </li>
					  <!-- ******************************** -->
					  <li class="sousmenu"><a href="#">Production</a>
						 <ul class="niveau2" <?php echo isHabilitation('Production',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>>
							<li class="sousmenu pro <?php echo isHabilitation('Aso',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="production/contrat/">Souscription contrat</a></li>
							<li class="sousmenu pro <?php echo isHabilitation('Ama',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="production/modadmin/">Modification administrative éléments du contrat</a></li>
							<li class="sousmenu pro <?php echo isHabilitation('Amc',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="production/modcontract/?idbloc=4&idfonction=42">Modification contractuelle éléments du contrat</a></li>
							<li class="sousmenu pro <?php echo isHabilitation('Are',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="production/resiliercontrat/">Résiliation contrat</a></li>
							<li class="sousmenu pro <?php echo isHabilitation('Arc',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="production/reactivationcontrat/">Réactivation contrat</a></li>
							<li class="sousmenu pro <?php echo isHabilitation('Ara',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="production/radiationassure/?idbloc=4&idfonction=45">Radiation assuré</a></li>
							<li class="sousmenu pro <?php echo isHabilitation('Area',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="production/reactivationassure/?idbloc=4&idfonction=46">Réactivation assuré</a></li>
							<li class="sousmenu pro <?php echo isHabilitation('Acc',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="production/changecouverture/?idbloc=4&idfonction=47">Changement de couverture</a></li>
							<li class="sousmenu pro <?php echo isHabilitation('Fre',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="production/reglementecheance/?idbloc=4&idfonction=48">Règlement d’une échéance</a></li>
						 </ul>
					  </li>
					  <!-- ******************************** -->
					  <li class="sousmenu"><a href="#">Sinistres</a>
						 <ul class="niveau2 n_sin" <?php echo isHabilitation('Sinistres',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>>
							<li class="sousmenu sin <?php echo isHabilitation('Sd',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="sinistres/declaration/?idbloc=5&idfonction=50">Déclaration sinistre</a></li>
							<li class="sousmenu sin <?php echo isHabilitation('Sj',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="sinistres/justificatif/?idbloc=5&idfonction=51">Justificatifs complémentaires déclaration sinistre</a></li>
							<li class="sousmenu sin <?php echo isHabilitation('Sri',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="sinistres/resultatinstruction/?idbloc=5&idfonction=52">Résultat instruction sinistre</a></li>
							<li class="sousmenu sin <?php echo isHabilitation('Frs',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="sinistres/reglement/?idbloc=5&idfonction=53">Règlement sinistre</a></li>
						 </ul>
					  </li>
					  <!-- ******************************** -->
					  <li class="sousmenu"><a <?php $ish = isHabilitation('Editions',$database_microassur, $microassur,$username_microassur, $password_microassur); if($ish) echo 'href="#"'; else echo 'href="menu.php"'; ?>>Editions</a>
					  	<ul class="niveau2 " >
							<li class="sousmenu <?php echo isHabilitation('Editions',$database_microassur, $microassur,$username_microassur, $password_microassur) ?>"><a href="editions/?idbloc=6&idfonction=60">Demande d'édition</a></li>
							
						 </ul>
					  </li>
					  <!-- ******************************** -->
				   </ul>
				</div>
				<div class="cleared"> </div>
		<?php 
				if(isset($_GET['msg']) && $_GET['msg']=='rattacheOffre')
					$message = colorer("Rattachement offre effectué","true");
				if(isset($_GET['msg']) && $_GET['msg']=='pbmSinistre')
					$message = colorer("Problème modification sinistre, déclaration sinistre, contactez la DSI","true"); //pbm_modification_sinistre
				if(isset($_GET['msg']) && $_GET['msg']=='pbmEventSinistre')
					$message = colorer("Problème création évènement, complément justificatifs, contacter la DSI","true"); //pbm_cre_event_justif_sinistre
			 
				if(isset($_GET['change_mot2pass']) && $_GET['change_mot2pass']=='success') 
					$message = colorer("Votre nouveau mot de passe est enregistré","true");
			 
				if(isset($_GET['annuler']))
					$message = colorer("Problème annulation souscription contrat, contactez la DSI","false");
				if(isset($_GET['ajoutevent1']))
					$message = colorer("Problème création évènement souscription contrat, contactez la DSI","false");
				if(isset($_GET['ajoutevent2']))
					$message = colorer("Problème création évènement règlement première échéance, contactez la DSI", "false");
					
				if(isset($_GET['msg']) && $_GET['msg']=='chgmt_couv_incomp')
					$message = colorer("Le changement de couverture est incomplet, vous devez saisir tous les éléments du contrat, à savoir le souscripteur, au moins un assuré, un bénéficiaire ou les ayants droit et le paiement","true"); //changement_couverture_incomplet
			 
				if(isset($_GET['ajouteventmodadmin']) && $_GET['ajouteventmodadmin']==0)
					$message = colorer("Problème création évènement modification administrative, contactez la DSI","false"); //err d inscription dans la table evenement
			 
				echo $message;
			
				//medoune
				if(isset($_GET['contrat_incomp']) && $_GET['contrat_incomp']==0)
				{
					echo colorer("Contrat ".$_SESSION['contrat']." créé avec succès !!!","false");
					
					$_SESSION['contrat']= NULL;
					unset($_SESSION['idcontrat']);
					unset($_SESSION['contrat']);
					unset($_SESSION['formule']);
					unset($_SESSION['produit']);
					unset($_SESSION['offre']);
					unset($_SESSION['dateeffet']);
					unset($_SESSION['tarif']);
					unset($_SESSION['idpers']);
					unset($_SESSION['freqpaiement']);
					unset($_SESSION['modpaiement']);
					unset($_SESSION['montantcotis']);							
					unset($_SESSION['refreglement']);
					unset($_SESSION['fraisecheance']);
					unset($_SESSION['datereglement']);
					unset($_SESSION['refreglement']);
					unset($_SESSION['montantecheanceregle']);
					unset($_SESSION['montantdroitentre']);
					unset($_SESSION['montantassure']);
					unset($_SESSION['montantcotisation']);
					unset($_SESSION['montantecheance']);
					unset($_SESSION['montantfraisecheance']);
				}
				
				if(isset($_GET['retour']))
				{
					unset($_SESSION['numcont']);
				}
			?>
			</div>
		<div class="cleared"> </div>
       
		<div class="corps">
		</div>
		<span id="ligne" style="position: relative;"><span id="dex"><a href="<?php echo $logoutAction ?>">Déconnexion</a></span></span>
</body>

</html>
<?php mysql_free_result($rs);?>
<?php ob_end_flush();  ?>